package com.ruoyi.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.ShopType;
import com.ruoyi.business.service.ShopTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**

 * 商铺类型Controller

 *

 * @author ruoyi

 * @date 2025-06-09
 */
@RestController
@RequestMapping("/system/type")
public class ShopTypeController extends BaseController
{
    @Autowired
    private ShopTypeService tbShopTypeService;

    /**

     * 查询商铺类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShopType shopType)
    {
        startPage();
        List<ShopType> list = tbShopTypeService.selectTbShopTypeList(shopType);
        return getDataTable(list);
    }

    /**

     * 导出商铺类型列表
     */
    @PreAuthorize("@ss.hasPermi('system:type:export')")
    @Log(title = "商铺类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShopType shopType)
    {
        List<ShopType> list = tbShopTypeService.selectTbShopTypeList(shopType);
        ExcelUtil<ShopType> util = new ExcelUtil<ShopType>(ShopType.class);
        util.exportExcel(response, list, "商铺类型数据");
    }

    /**

     * 获取商铺类型详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:type:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(tbShopTypeService.selectTbShopTypeById(id));
    }

    /**

     * 新增商铺类型
     */
    @PreAuthorize("@ss.hasPermi('system:type:add')")
    @Log(title = "商铺类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShopType shopType)
    {
        return toAjax(tbShopTypeService.insertTbShopType(shopType));
    }

    /**

     * 修改商铺类型
     */
    @PreAuthorize("@ss.hasPermi('system:type:edit')")
    @Log(title = "商铺类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShopType shopType)
    {
        return toAjax(tbShopTypeService.updateTbShopType(shopType));
    }

    /**

     * 删除商铺类型
     */
    @PreAuthorize("@ss.hasPermi('system:type:remove')")
    @Log(title = "商铺类型", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(tbShopTypeService.deleteTbShopTypeByIds(ids));
    }
}